﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/mobile_H.Master" Inherits="System.Web.Mvc.ViewPage<Bias_Stock.Models.CountCartModel.Cart_CNT_DS>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    Exit_data
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <style type="text/css">
        tr
        {
            height: 35px;
            text-align: right;
            background-color: #fff;
        }
        tr.dis
        {
            background-color: #FFFFC2;
        }
    </style>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="FeaturedContent" runat="server">
    <div style="background-color: #8094AE; height: 50px; margin-top: 0px;">
        <h2 style="color: White; vertical-align: middle;">
            &nbsp;DATA EXIST</h2>
    </div>
    <div id="page1">
        <table style="width: 100%; font-size: medium; color: #004080; padding: 5px; font-weight: bold;">
            <tr class="dis">
                <td style="width: 30%; text-align: right;">
                    DATETIME :
                </td>
                <td style="text-align: left;">
                    <%: Model._Count_date %>
                </td>
            </tr>
            <tr class="dis">
                <td>
                    EMP : &nbsp;
                </td>
                <td style="text-align: left;">
                    <%: Model._user%>
                </td>
            </tr>
            <tr class="dis">
                <td>
                    Area : &nbsp;
                </td>
                <td style="text-align: left;">
                    <%: Model._Area %>
                </td>
            </tr>
            <tr class="dis">
                <td>
                    Cart : &nbsp;
                </td>
                <td style="text-align: left;">
                    <%: Model._Cart_no %>
                </td>
            </tr>
            <% if (WinNemoLib.StrUtil.IsNotEmpty(Model._Blank))
               { %>
            <tr class="dis">
                <td>
                    Blank : &nbsp;
                </td>
                <td style="text-align: left;">
                    <%: Model._Blank%>
                </td>
            </tr>
            <% }
               else
               { %>
            <tr class="dis">
                <td>
                    Size : &nbsp;
                </td>
                <td style="text-align: left;">
                    <%: Model._Size %>
                </td>
            </tr>
            <tr class="dis">
                <td>
                    PLY : &nbsp;
                </td>
                <td style="text-align: left;">
                    <%: Model._Ply %>
                </td>
            </tr>
            <tr class="dis">
                <td>
                    M. : &nbsp;
                </td>
                <td style="text-align: left;">
                    <%: Model._Meter %>
                </td>
            </tr>
            <% } %>
        </table>
        <div style="float: left">
            <input type="button" id="back" value="Cancel" style="width: 40%" /></div>
        <div style="float: right; width: 45%">
            <input type="button" id="next" value="&nbsp;NEXT&nbsp;" style="width: 100%" /></div>
    </div>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="ScriptsSection" runat="server">
    <% if (false)
       { %>
    <script src="../../Scripts/jquery-1.7.1.js" type="text/javascript"></script>
    <% } %>
    <script type="text/jscript">
        $(function () {
            $("#back").click(function () {
                window.location = '<%= Url.Action("Cart_Tag") %>' + '?area=' + '<%: Bias_Stock.Models.SessionBag.Current.area %>';
            });

            $("#next").click(function () {
                //window.location = '<%= Url.Action("Count_Tag") %>' + '?area=' + '<%: Bias_Stock.Models.SessionBag.Current.area %>'+ '&cart=' + '<%: Model._Cart_no %>' + '&rep=true';
                if ('<%: Model._tag %>' == "") {
                    Save_blank();
                } else {
                    $.post('<%= Url.Action("GetTag") %>' + '?tag=' + encodeURIComponent('<%: Model._tag %>'), function (data) {
                        if (data != "") {
                            alert(data);
                            window.location = '<%= Url.Action("Count_Tag") %>' + '?area=' + '<%: Bias_Stock.Models.SessionBag.Current.area %>' + '&cart=' + '<%: Model._Cart_no %>' + '&rep=true';
                            return;
                        }
                        else {
                            Comp_cart()
                            window.location = '<%= Url.Action("Tag_Cart") %>' + '?tag=' + encodeURIComponent('<%: Model._tag %>') + "&area=" + '<%: Bias_Stock.Models.SessionBag.Current.area %>' + '&cartno=' + '<%: Model._Cart_no %>';
                        }
                    });

                }

            });
            function Save_blank() {

                var dataForSubmit = new Array();
                dataForSubmit.push({
                    _area: '<%: Bias_Stock.Models.SessionBag.Current.area %>'
                });
                var getUsersUrl = '<%= Url.Action("Blank_Cart") %>';
                callScriptMethod(getUsersUrl, { theData: dataForSubmit, cartno: '<%: Model._Cart_no %>' });

            }

            function callScriptMethod(url, jsonObject, action, callback, async) {

                callback = callback || function () { };
                async = (async == null || async);

                $.ajax({
                    type: "POST",
                    contentType: "application/json; charset=utf-8",
                    url: url,
                    data: JSON.stringify(jsonObject),
                    dataType: "json",
                    async: async,
                    success: function (data) {

                        if (data.success != "1") {
                            alert(data.message);
                        } else {

                            alert("Save Complete");
                            window.location = '<%= Url.Action("Cart_Tag") %>' + '?area=' + '<%: Bias_Stock.Models.SessionBag.Current.area %>'
                        }
                    },
                    error: function (xhr, status, error) {
                        var err = xhr.responseText;
                        alert(err.Message);
                    }
                });
            }

            function Comp_cart() {
                var cartno = '<%: Model._Cart_no %>';
                $.post('<%= Url.Action("GetCartno") %>' + '?tag=' + encodeURIComponent('<%: Model._tag %>')
            , function (data) {
                if (cartno != data) {
                    alert("This tag doesn't match cart no. " + cartno);
                    return false;
                }
                return true;
            });
            }

        });
    </script>
</asp:Content>
